//
//  HTWaybillFooterCell.m
//  TruckDriver
//
//  Created by Ting Han on 2017/10/26.
//  Copyright © 2017年 Ting Han. All rights reserved.
//

#import "HTWaybillFooterCell.h"
#import "UIView+Layout.h"

@interface HTWaybillFooterCell()

@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
@property (weak, nonatomic) IBOutlet UILabel *iconLabel;

@end

@implementation HTWaybillFooterCell

- (void)setupSubView{
    
    NSArray *array = [self.impressString componentsSeparatedByString:@","];
    NSMutableArray  *viewArray = [NSMutableArray arrayWithCapacity:3];
    for (NSString *title in array) {
        if ([self.scrollString integerValue] == 3) {//好评
            
            HTCommentShowView *showView = [[HTCommentShowView alloc]initWithFrame:CGRectMake(self.iconImageView.left, self.iconImageView.bottom + 18, 100, 30) Title:title withHightComment:YES];
            [viewArray addObject:showView];
            [self addSubview:showView];
        }else{
            HTCommentShowView *showView = [[HTCommentShowView alloc]initWithFrame:CGRectMake(self.iconImageView.left, self.iconImageView.bottom + 18, 100, 30) Title:title withHightComment:NO];
            [viewArray addObject:showView];
            [self addSubview:showView];
        }
    }
    for (int i= 1; i< viewArray.count; i++) {
        HTCommentShowView *showViewLast = viewArray[i-1];
        HTCommentShowView *showView = viewArray[i];
        if (self.right - showViewLast.right - 8 < showView.width) {
            showView.frame = CGRectMake(self.iconImageView.left, showViewLast.bottom + 18, showView.width, showView.height);
        }else{
            showView.frame = CGRectMake(showViewLast.right + 18, showViewLast.top, showView.width, showView.height);
        }
    }
    switch ([self.scrollString integerValue]) {
        case 0:
        {
            self.iconLabel.text = @"未评价";
            self.iconImageView.image = [UIImage imageNamed:@"icon-highpraise-select"];
        }
            break;
        case 1://差评
            
        {
            self.iconLabel.text = @"差评";
            self.iconImageView.image = [UIImage imageNamed:@"icon-lowpraise-select"];
            
        }
            break;
        case 2://一般
        {
            self.iconLabel.text = @"一般";
            self.iconImageView.image = [UIImage imageNamed:@"icon-middlepraise-select"];
            
        }
            break;
        case 3://好评
        {
            self.iconLabel.text = @"好评";
            self.iconImageView.image = [UIImage imageNamed:@"icon-highpraise-select"];
        }
            break;
            
        default:
            break;
    }
    
}


- (void)awakeFromNib {
    [super awakeFromNib];
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}

@end
